
//
//  SeachAddressView.m
//  Experss
//
//  Created by 嗯，大葱 on 17/8/4.
//  Copyright © 2017年 嗯，大葱. All rights reserved.
//

#import "SeachAddressView.h"
#import "SeachAddressCell.h"

#import <AMapSearchKit/AMapSearchKit.h>

@implementation SeachAddressView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        
        
    }
    return self;
}
- (void)setDataArray:(NSMutableArray *)dataArray {
    if (_dataArray) {
        [_dataArray removeAllObjects];
    }
    _dataArray = dataArray;
    
    [self configureView];

}


- (void)configureView {
    
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kView_Width, kView_Height)];
    _tableView.dataSource = self;
    _tableView.delegate = self;
    [self addSubview:_tableView];
    [_tableView registerNib:[UINib nibWithNibName:@"SeachAddressCell" bundle:nil] forCellReuseIdentifier:@"SeachAddressCell"];
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _dataArray.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 75;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    SeachAddressCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SeachAddressCell"];
     AMapPOI *pointD = _dataArray[indexPath.row];
    cell.tiltLB.text = pointD.address;
    cell.titlLB2.text = pointD.name;
    return cell;
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
     AMapPOI *pointD = _dataArray[indexPath.row];
    if(self.delegate && [self.delegate respondsToSelector:@selector(seleIndepathTitleStr:nameStr:)])
    {
        [self.delegate seleIndepathTitleStr:pointD.address nameStr:pointD.name];
    }
}




@end
